package Practice.Practice_02.UserManagementSystem;

import java.util.Objects;
import java.util.Scanner;

public class Registration {
    public static void register(Person[] person) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入账号：");
        String user = sc.next();
        System.out.println("请输入密码：");
        String pass = sc.next();
        System.out.println("请输入邮箱：");
        String mail = sc.next();
        for (int i = 0; i < person.length; i++) {
            if(Objects.equals(person[i].getName(), user)){
                System.out.println("该账号已注册！");
                System.out.println("=========================");
                break;
            }else if(Objects.equals(person[i].getName(), "-1")){
                person[i].setId(i);
                person[i].setName(user);
                person[i].setPass(pass);
                person[i].setEmail(mail);
                person[i].setPower("普通用户");
                System.out.println("注册成功。。。");
                System.out.println("=========================");
                break;
            }
        }
    }
}
